<?php

namespace app\base\model\order;

use think\Model;

class Order extends Model
{

    // 关闭自动写入时间戳
    protected $autoWriteTimestamp = false;

    protected $table = 'xy_order.xy_order';

    const ORDER_NOT_PAY = 0;//订单状态(未支付)
    const ORDER_SUCCESS = 1;//订单状态(支付成功)
    const ORDER_CANCEL = 2;//订单状态(已取消)
    const ORDER_REFUND = 3;//订单状态(已退款)

    const PAY_WAY_WX_MINI = 1;//支付来源(微信小程序)
    const PAY_WAY_APP = 2;//支付来源(APP)
    const PAY_WAY_ADMIN = 3;//支付来源(后台机器人)


    const PAY_MODE_WX_PAY = 1;//支付方式(微信)
    const PAY_MODE_ALI_PAY = 2;//支付方式(支付宝)
    const PAY_MODE_APPLE_STORE = 3;//支付方式(苹果商店)

    public static function hasPay($user_id)
    {
        return self::where('user_id', $user_id)->where('order_state', self::ORDER_SUCCESS)->count();
    }

}